package com.whj.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    public WebMvcConfig() {
        System.out.println("=== WebMvcConfig 构造函数被调用 ===");
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        System.out.println("=== 开始配置资源处理器 ===");

        registry.addResourceHandler("/profile/**")
                .addResourceLocations("file:D:/ruoyi/uploadPath/");
        registry.addResourceHandler("/uploads/**")
                .addResourceLocations("file:C:/loan_uploads");
        System.out.println("已添加资源映射: /profile/** -> file:D:/ruoyi/uploadPath/upload/");
        System.out.println("=== 资源处理器配置完成 ===");
    }
    @Bean
    public BCryptPasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }
}


